// import { lazy } from 'react'
import { Navigate, useRoutes } from 'react-router-dom'
import { RoutersProps } from "./interface/index"
import AuthEntry from "@/pages/authEntry/index"
import Cockpit from "@/pages/cockpit/index"
import Home from "@/pages/home/index"
import NotFound from "@/pages/404/index"
import NoAccess from '@/pages/noAccess'

const constantRoutes: RoutersProps[] = [
    {
        path: '/',
        element: <Navigate to="authEntry" />,

        meta: { title: '神鸟' }
    },
    {
        path: 'authEntry',
        element: <AuthEntry />,
        meta: { title: '神鸟' }
    },
    {
        path: 'cockpit',        // 首页
        element: <Cockpit />,
        meta:{title: '神鸟' }
    },
    {
        path: 'home',        // 首页
        element: <Home />,
        meta: { title: '神鸟' }
    },
    {
        path: 'noAccess',
        element: <NoAccess />,
        meta: { title: '驾驶舱' }
    },
    {
        path: '/error/404',
        element: <NotFound />,
        meta: { title: 'not found' }
    },
]

// function filterAsyncRouter(routes: RoutersProps[], routers: RoutersProps[]) {

//     const viteModule = require['context']('../pages', true, /\.tsx/)

//     return routers
// }

// function useLazy(routes: RoutersProps[]) {
//     const tempRoutes: RoutersProps[] = []
//     filterAsyncRouter(routes, tempRoutes)
//     constantRoutes.push(...tempRoutes)
//     constantRoutes.push({
//         path: '*',
//         element: <Navigate to="/error/404" />
//     })
// }

const Router = () => useRoutes(constantRoutes)

// export { Router, useLazy } 
export { Router } 